/*
 * =====================================================================================
 *
 *       Filename:  test_open_simple.c
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  03/29/16 18:02:03
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Andy (gk), andy_y_li@163.com
 *        Company:  RD
 *
 * =====================================================================================
 */

#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <popen.h>

#define ShellCommand "JLinkExe"

int main()
{
    char buffer[1024];
    memset(buffer,'\0', sizeof(buffer));
    //FILE *fp = popen("ls -l", "r");
    //FILE *fp = re_popen("bcd-cli.app --usbcdc", "r");
    FILE *fp = re_popen(ShellCommand, "r");
    printf("end of popen...\n");
    //sleep(3);
    fread(buffer, sizeof(buffer), 1, fp);
    //fgets(buffer, sizeof(buffer), fp);
    printf("tttt%s\n", buffer);
    fwrite("q\n", 1, 3, fp);
    re_pclose(fp);

    return 0;

}

